<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/css/fishc.css">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
{#    <textarea id="textarea"></textarea>#}
    <div style="position: absolute">
        <button class="layui-btn" onclick="generate_a_poem_at_random();">随机生成一首诗</button><br>
        <button class="layui-btn" onclick="with_partial_information_given();">给出部分诗句，随机生成剩余部分</button><br>
        <button class="layui-btn" onclick="generate_tibetan_poems();">输入头部，生成藏头诗</button>
    </div>

    <div id="text"></div>
    <div id="jsi-cherry-container" class="container"></div>
</body>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/run.js"></script>
<script src="/static/js/fishc.js"></script>
<script src="/static/layui/layui.js"></script>
<script src="/static/js/layer.js"></script>
<script>
    RENDERER.init();
    function generate_a_poem_at_random(){
        document.getElementById("text").innerHTML="生成中...";
        $.get(
            "/generate_a_poem_at_random",
            function (data,status) {
                console.log(status);
                document.getElementById("text").innerHTML="";
                $(function(){
                    text({
                        str: data,
                        effect: "random",
                        speed : 111,
                    });
                }
            );
        });
    }
    function with_partial_information_given(){
        document.getElementById("text").innerHTML="生成中...";
        //例子1
        layer.prompt(function(value, index, elem){
          {#alert(value); //得到value#}
            $.get(
                "/with_partial_information_given",
                {
                    "info": value
                },
                function (data,status) {
                    document.getElementById("text").innerHTML="";
                    $(function(){
                        text({
                            str: data,
                            effect: "random",
                            speed : 111,
                        });
                    }
                );
            });
          layer.close(index);
        });

    }
    function generate_tibetan_poems(){
        document.getElementById("text").innerHTML="生成中...";
        //例子1
        layer.prompt(function(value, index, elem){
          {#alert(value); //得到value#}
            $.get(
                "/generate_tibetan_poems",
                {
                    "info": value
                },
                function (data,status) {
                    document.getElementById("text").innerHTML="";
                    $(function(){
                        text({
                            str: data,
                            effect: "random",
                            speed : 111,
                        });
                    }
                );
            });
          layer.close(index);
        });
    }
</script>
</html>
